﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

public partial class insertQLSanPham : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void btQuayLai_Click(object sender, EventArgs e)
    {
        Response.Redirect("QLSanPham.aspx");
    }
    protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
    {

    }
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        System.Threading.Thread.Sleep(5000);
        if (AsyncFileUpload1.HasFile)
        {
            string strPathFile = "~/AnhSP/";

            if (!Directory.Exists(Server.MapPath(strPathFile))) //Nếu folder không tồn tại
            {
                //Tạo folder
                Directory.CreateDirectory(Server.MapPath(strPathFile));
            }

            string strPath = MapPath(strPathFile) + Path.GetFileName(e.FileName);
            AsyncFileUpload1.SaveAs(strPath);
        }
    }

    protected void btTurnOnUpload_Click(object sender, EventArgs e)
    {
        AsyncFileUpload1.Visible = true;
        Label7.Visible = true;
    }

    protected void btTurnOffUpload_Click(object sender, EventArgs e)
    {
        AsyncFileUpload1.Visible = false;
        Label7.Visible = false;
    }
}